The following diagram shows the transaction behavior that N4 inherits from Hibernate. Whenever a flush is called in the transaction, it triggers an update or insert to the database (if there are any inserts or updates in the memory since the last flush). As a part of this process, N4 calls any life cycle interceptors (code extensions) defined for the changed entities.
A "Flush" represents the step where the SQL queries are written to the database. Hibernate calls the appropriate Validation hooks to ensure that the SQL written to the database is in a valid state.
Your extension is called whenever a hibernate flush occurs.
A Flush can be invoked multiple times.
The Life Cycle Interceptor (LCI) code should be tolerant of multiple invocations in a single transaction.
Understanding Transaction Boundaries
You must understand:
Where the transaction boundaries are, so that you can understand what an error means and who is responsible for handling that error.
That certain actions, such as JMS or external Web services, are outside the main transaction.
If you send a JMS message in an entity interceptor, you are sending the message before the transaction is completed and the transaction may still exit with an error. You must use the Notice Events to send the JMS messages.